<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="model.User"%>
<%@ page import="control.UserControl"%>
<%@ page import="util.ParamUtil;"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    <title>My JSP 'user_update_chuli.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%
     request.setCharacterEncoding("UTF-8");
     int id=ParamUtil.getInt(request,"id",0);
     String user_name=ParamUtil.getString(request,"user_name");
     String user_pwd2=ParamUtil.getString(request,"user_pwd2");
  	 String user_pwd3=ParamUtil.getString(request,"user_pwd3");
     User user=new User();
     user.setUsername(user_name);
	 user.setPassword(user_pwd2);
	 if(user_pwd2.equals(user_pwd3))
	 {
		if(UserControl.updateUser(user,id))
		{
		    session.removeAttribute("username");
			session.removeAttribute("pwd");
  		    session.setAttribute("username",user_name); 
			session.setAttribute("pwd",user_pwd2);
  				%>
		<script language="javascript">
  				alert("修改成功");
  				window.location.href="user_update.jsp";
  				</script>
		<%} else { %>
		<script language="javascript">
  				alert("修改失败");
  				history.back();
  				</script>
		<%} 
  		}
  		else 
  		{%>
		<script language="javascript">
  			alert("密码错误或密码不一致");
  	        history.back();
  			</script>
		<%}
  %>
  </body>
</html>
